﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MixingStation
{
    public partial class WeightModifyForm : Form
    {
        private WeightModifyType m_WeightModifyType = WeightModifyType.Gross;

        private string m_CarCode;
        public string CarCode
        {
            set { m_CarCode = value; }
        }

        private int m_OriginWeight;
        public int OriginWeight
        {
            set { m_OriginWeight = value; }
        }

        private int m_NewWeight;
        public int NewWeight
        {
            get { return m_NewWeight; }
        }

        public WeightModifyForm(WeightModifyType type)
        {
            InitializeComponent();
            m_WeightModifyType = type;
        }

        private void WeightModifyForm_Load(object sender, EventArgs e)
        {
            if (m_WeightModifyType == WeightModifyType.Gross)
            {
                this.lciOriginalWeight.Text = "原毛重";
                this.lciNewWeight.Text = "新毛重";
                this.Text = "毛重修改";
            }
            else if (m_WeightModifyType == WeightModifyType.Tare)
            {
                this.lciOriginalWeight.Text = "原皮重";
                this.lciNewWeight.Text = "新皮重";
                this.Text = "皮重修改";
            }
            else if (m_WeightModifyType == WeightModifyType.Buckle)
            {
                this.lciOriginalWeight.Text = "原扣杂";
                this.lciNewWeight.Text = "新扣杂";
                this.Text = "扣杂修改";
            }
            else if (m_WeightModifyType == WeightModifyType.Delivery)
            {
                this.lciOriginalWeight.Text = "原送货重量";
                this.lciNewWeight.Text = "新送货重量";
                this.Text = "送货重量修改";
            }
            this.txtCarCode.Text = m_CarCode;
            this.txtOriginalWeight.Text = m_OriginWeight.ToString();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            int.TryParse(this.txtNewWeight.Text.Trim(), out m_NewWeight);
            if (m_NewWeight <= 0)
            {
                MessageBox.Show(this, "新重量不能小于等于0！");
                return;
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
    }

    public enum WeightModifyType : int
    {
        Gross = 0,
        Tare = 1,
        Buckle = 2,
        Delivery = 3
    }
}
